﻿namespace Chain.Common.WebReference
{
    using Chain.Common.Properties;
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Threading;
    using System.Web.Services;
    using System.Web.Services.Description;
    using System.Web.Services.Protocols;

    [DebuggerStepThrough, GeneratedCode("System.Web.Services", "4.0.30319.1"), DesignerCategory("code"), WebServiceBinding(Name="SmsServiceSoap", Namespace="http://tempuri.org/")]
    public class SmsService : SoapHttpClientProtocol
    {
        private GetBalanceCompletedEventHandler GetBalanceCompleted;
        private SendOrPostCallback GetBalanceOperationCompleted;
        private RegisterExCompletedEventHandler RegisterExCompleted;
        private SendOrPostCallback RegisterExOperationCompleted;
        private RegisterZsCompletedEventHandler RegisterZsCompleted;
        private SendOrPostCallback RegisterZsOperationCompleted;
        private SendMessageCompletedEventHandler SendMessageCompleted;
        private SendOrPostCallback SendMessageOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;

        public event GetBalanceCompletedEventHandler _GetBalanceCompleted
        {
            add
            {
                GetBalanceCompletedEventHandler handler2;
                GetBalanceCompletedEventHandler getBalanceCompleted = this.GetBalanceCompleted;
                do
                {
                    handler2 = getBalanceCompleted;
                    GetBalanceCompletedEventHandler handler3 = (GetBalanceCompletedEventHandler) Delegate.Combine(handler2, value);
                    getBalanceCompleted = Interlocked.CompareExchange<GetBalanceCompletedEventHandler>(ref this.GetBalanceCompleted, handler3, handler2);
                }
                while (getBalanceCompleted != handler2);
            }
            remove
            {
                GetBalanceCompletedEventHandler handler2;
                GetBalanceCompletedEventHandler getBalanceCompleted = this.GetBalanceCompleted;
                do
                {
                    handler2 = getBalanceCompleted;
                    GetBalanceCompletedEventHandler handler3 = (GetBalanceCompletedEventHandler) Delegate.Remove(handler2, value);
                    getBalanceCompleted = Interlocked.CompareExchange<GetBalanceCompletedEventHandler>(ref this.GetBalanceCompleted, handler3, handler2);
                }
                while (getBalanceCompleted != handler2);
            }
        }

        public event RegisterExCompletedEventHandler _RegisterExCompleted
        {
            add
            {
                RegisterExCompletedEventHandler handler2;
                RegisterExCompletedEventHandler registerExCompleted = this.RegisterExCompleted;
                do
                {
                    handler2 = registerExCompleted;
                    RegisterExCompletedEventHandler handler3 = (RegisterExCompletedEventHandler) Delegate.Combine(handler2, value);
                    registerExCompleted = Interlocked.CompareExchange<RegisterExCompletedEventHandler>(ref this.RegisterExCompleted, handler3, handler2);
                }
                while (registerExCompleted != handler2);
            }
            remove
            {
                RegisterExCompletedEventHandler handler2;
                RegisterExCompletedEventHandler registerExCompleted = this.RegisterExCompleted;
                do
                {
                    handler2 = registerExCompleted;
                    RegisterExCompletedEventHandler handler3 = (RegisterExCompletedEventHandler) Delegate.Remove(handler2, value);
                    registerExCompleted = Interlocked.CompareExchange<RegisterExCompletedEventHandler>(ref this.RegisterExCompleted, handler3, handler2);
                }
                while (registerExCompleted != handler2);
            }
        }

        public event RegisterZsCompletedEventHandler _RegisterZsCompleted
        {
            add
            {
                RegisterZsCompletedEventHandler handler2;
                RegisterZsCompletedEventHandler registerZsCompleted = this.RegisterZsCompleted;
                do
                {
                    handler2 = registerZsCompleted;
                    RegisterZsCompletedEventHandler handler3 = (RegisterZsCompletedEventHandler) Delegate.Combine(handler2, value);
                    registerZsCompleted = Interlocked.CompareExchange<RegisterZsCompletedEventHandler>(ref this.RegisterZsCompleted, handler3, handler2);
                }
                while (registerZsCompleted != handler2);
            }
            remove
            {
                RegisterZsCompletedEventHandler handler2;
                RegisterZsCompletedEventHandler registerZsCompleted = this.RegisterZsCompleted;
                do
                {
                    handler2 = registerZsCompleted;
                    RegisterZsCompletedEventHandler handler3 = (RegisterZsCompletedEventHandler) Delegate.Remove(handler2, value);
                    registerZsCompleted = Interlocked.CompareExchange<RegisterZsCompletedEventHandler>(ref this.RegisterZsCompleted, handler3, handler2);
                }
                while (registerZsCompleted != handler2);
            }
        }

        public event SendMessageCompletedEventHandler _SendMessageCompleted
        {
            add
            {
                SendMessageCompletedEventHandler handler2;
                SendMessageCompletedEventHandler sendMessageCompleted = this.SendMessageCompleted;
                do
                {
                    handler2 = sendMessageCompleted;
                    SendMessageCompletedEventHandler handler3 = (SendMessageCompletedEventHandler) Delegate.Combine(handler2, value);
                    sendMessageCompleted = Interlocked.CompareExchange<SendMessageCompletedEventHandler>(ref this.SendMessageCompleted, handler3, handler2);
                }
                while (sendMessageCompleted != handler2);
            }
            remove
            {
                SendMessageCompletedEventHandler handler2;
                SendMessageCompletedEventHandler sendMessageCompleted = this.SendMessageCompleted;
                do
                {
                    handler2 = sendMessageCompleted;
                    SendMessageCompletedEventHandler handler3 = (SendMessageCompletedEventHandler) Delegate.Remove(handler2, value);
                    sendMessageCompleted = Interlocked.CompareExchange<SendMessageCompletedEventHandler>(ref this.SendMessageCompleted, handler3, handler2);
                }
                while (sendMessageCompleted != handler2);
            }
        }

        public SmsService()
        {
            this.Url = Settings.Default.Chain_Common_WebReference_SmsService;
            if (this.IsLocalFileSystemWebService(this.Url))
            {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else
            {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }

        public void CancelAsync(object userState)
        {
            base.CancelAsync(userState);
        }

        [SoapDocumentMethod("http://tempuri.org/GetBalance", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string GetBalance(int intSmsType, string strSmsSeries, string strSmsSerialPwd)
        {
            return (string) base.Invoke("GetBalance", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd })[0];
        }

        public void GetBalanceAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd)
        {
            this.GetBalanceAsync(intSmsType, strSmsSeries, strSmsSerialPwd, null);
        }

        public void GetBalanceAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, object userState)
        {
            if (this.GetBalanceOperationCompleted == null)
            {
                this.GetBalanceOperationCompleted = new SendOrPostCallback(this.OnGetBalanceOperationCompleted);
            }
            base.InvokeAsync("GetBalance", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd }, this.GetBalanceOperationCompleted, userState);
        }

        private bool IsLocalFileSystemWebService(string url)
        {
            if ((url == null) || (url == string.Empty))
            {
                return false;
            }
            Uri uri = new Uri(url);
            return ((uri.Port >= 0x400) && (string.Compare(uri.Host, "localHost", StringComparison.OrdinalIgnoreCase) == 0));
        }

        private void OnGetBalanceOperationCompleted(object arg)
        {
            if (this.GetBalanceCompleted != null)
            {
                InvokeCompletedEventArgs args = (InvokeCompletedEventArgs) arg;
                this.GetBalanceCompleted(this, new GetBalanceCompletedEventArgs(args.Results, args.Error, args.Cancelled, args.UserState));
            }
        }

        private void OnRegisterExOperationCompleted(object arg)
        {
            if (this.RegisterExCompleted != null)
            {
                InvokeCompletedEventArgs args = (InvokeCompletedEventArgs) arg;
                this.RegisterExCompleted(this, new RegisterExCompletedEventArgs(args.Results, args.Error, args.Cancelled, args.UserState));
            }
        }

        private void OnRegisterZsOperationCompleted(object arg)
        {
            if (this.RegisterZsCompleted != null)
            {
                InvokeCompletedEventArgs args = (InvokeCompletedEventArgs) arg;
                this.RegisterZsCompleted(this, new RegisterZsCompletedEventArgs(args.Results, args.Error, args.Cancelled, args.UserState));
            }
        }

        private void OnSendMessageOperationCompleted(object arg)
        {
            if (this.SendMessageCompleted != null)
            {
                InvokeCompletedEventArgs args = (InvokeCompletedEventArgs) arg;
                this.SendMessageCompleted(this, new SendMessageCompletedEventArgs(args.Results, args.Error, args.Cancelled, args.UserState));
            }
        }

        [SoapDocumentMethod("http://tempuri.org/RegisterEx", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string RegisterEx(string softwareSerialNo, string key, string serialpass)
        {
            return (string) base.Invoke("RegisterEx", new object[] { softwareSerialNo, key, serialpass })[0];
        }

        public void RegisterExAsync(string softwareSerialNo, string key, string serialpass)
        {
            this.RegisterExAsync(softwareSerialNo, key, serialpass, null);
        }

        public void RegisterExAsync(string softwareSerialNo, string key, string serialpass, object userState)
        {
            if (this.RegisterExOperationCompleted == null)
            {
                this.RegisterExOperationCompleted = new SendOrPostCallback(this.OnRegisterExOperationCompleted);
            }
            base.InvokeAsync("RegisterEx", new object[] { softwareSerialNo, key, serialpass }, this.RegisterExOperationCompleted, userState);
        }

        [SoapDocumentMethod("http://tempuri.org/RegisterZs", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string RegisterZs(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign)
        {
            return (string) base.Invoke("RegisterZs", new object[] { sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign })[0];
        }

        public void RegisterZsAsync(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign)
        {
            this.RegisterZsAsync(sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign, null);
        }

        public void RegisterZsAsync(string sn, string pwd, string province, string city, string trade, string entname, string linkman, string phone, string mobile, string email, string fax, string address, string postcode, string sign, object userState)
        {
            if (this.RegisterZsOperationCompleted == null)
            {
                this.RegisterZsOperationCompleted = new SendOrPostCallback(this.OnRegisterZsOperationCompleted);
            }
            base.InvokeAsync("RegisterZs", new object[] { sn, pwd, province, city, trade, entname, linkman, phone, mobile, email, fax, address, postcode, sign }, this.RegisterZsOperationCompleted, userState);
        }

        [SoapDocumentMethod("http://tempuri.org/SendMessage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
        public string SendMessage(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime)
        {
            return (string) base.Invoke("SendMessage", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime })[0];
        }

        public void SendMessageAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime)
        {
            this.SendMessageAsync(intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime, null);
        }

        public void SendMessageAsync(int intSmsType, string strSmsSeries, string strSmsSerialPwd, string strSmsMobileList, string strSmsContent, string strSmsTime, object userState)
        {
            if (this.SendMessageOperationCompleted == null)
            {
                this.SendMessageOperationCompleted = new SendOrPostCallback(this.OnSendMessageOperationCompleted);
            }
            base.InvokeAsync("SendMessage", new object[] { intSmsType, strSmsSeries, strSmsSerialPwd, strSmsMobileList, strSmsContent, strSmsTime }, this.SendMessageOperationCompleted, userState);
        }

        public string Url
        {
            get
            {
                return base.Url;
            }
            set
            {
                if ((this.IsLocalFileSystemWebService(base.Url) && !this.useDefaultCredentialsSetExplicitly) && !this.IsLocalFileSystemWebService(value))
                {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }

        public bool UseDefaultCredentials
        {
            get
            {
                return base.UseDefaultCredentials;
            }
            set
            {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
    }
}

